﻿Public Class DRUGUSE2
    Dim PROVIDER_Check As New PROVIDERSCLASS
    Dim connect As CONDB = CONDB.NewConnection()

    Dim stopTEvent As Integer = 0

    '------auto drug label section-------
    Dim useTextTH As String = ""
    Dim useTextEN As String = ""
    Dim unitTH As String = ""
    Dim unitEN As String = ""
    Dim publicQlabel As String
    Dim publicQlabel_en As String
    Dim publicMlabel As String
    Dim publicMlabel_en As String
    '------end of auto drug label section--------

    Private Sub queryFrndrguseGrid()
        Dim objSelectFrndrguse As New DRUGUSE2CLASS
        Dim dt As DataTable = connect.GetTable(objSelectFrndrguse.selectFrndrguse_)
        frndruguseGrid.PrimaryGrid.DataSource = dt
    End Sub

    Private Sub queryFilterFrndrguseGrid(prdcode As Integer)
        Dim objSelectFilterFrndrguse As New DRUGUSE2CLASS
        frndruguseGrid.PrimaryGrid.DataSource = objSelectFilterFrndrguse.selectFilterFrndrguse(prdcode)
    End Sub

    'Private Sub filterDrugitem()
    '    Dim s2 As FILTERCLASS
    '    Dim sql2 As String = "SELECT CAST(PRDCODE AS CHAR(8)) AS PRDCODE, `GENERICNAME`, `DRGCODE`, `TRADENAME`, `KWORD` FROM drugitem WHERE STATUS = '1'"
    '    s2 = New FILTERCLASS(PRDCODETxt, sql2, "รหัสผลิตภัณฑ์,ชื่อสามัญ,รหัสยา,ชื่อการค้า,Keyword", "50,160,50,160", "1,1,1,1", "1,1,1,1")
    '    's.SetShowInDown = False
    '    s2.SetShowBorder = True
    'End Sub

    Private Sub filterDrugitem()
        Dim s2 As FILTERCLASS
        Dim sql2 As String = "SELECT CAST(DRGCODE AS CHAR(8)) AS DRGCODE, `GENERICNAME`, `TRADENAME`, `KWORD` FROM drugitem WHERE STATUS = '1'"
        s2 = New FILTERCLASS(DRGCODETxt, sql2, "รหัสยา,ชื่อสามัญ,ชื่อการค้า,Keyword", "50,160,160", "1,1,1", "1,1,1")
        's.SetShowInDown = False
        s2.SetShowBorder = True
    End Sub

    Private Sub filterMasdrguse()
        Dim s2 As FILTERCLASS
        Dim sql2 As String = "SELECT CAST(USEID AS CHAR(8)) AS USEID, `DUSENAME`, `DUSENAME_EN`, `UGID` FROM masdrguse WHERE STATUS = '1'"
        s2 = New FILTERCLASS(masdrguseTxt, sql2, "รหัส,วิธีใช้(ไทย),วิธีใช้(อังกฤษ),คำย่อ", "50,160,160,50", "1,1,1,1", "1,1,1,1")
        's.SetShowInDown = False
        s2.SetShowBorder = True
    End Sub

    Private Sub filterMasdrgcuse()
        Dim s2 As FILTERCLASS
        Dim sql2 As String = "SELECT CAST(dcuid AS CHAR(8)) AS dcuid, `code`, `qlabel`, `qlabel_en`, `mlabel`, `mlabel_en` FROM masdrgcuse WHERE STATUS = '1'"
        s2 = New FILTERCLASS(txtDrgcuse, sql2, "รหัส,code,วิธีใช้(ไทย),วิธีใช้(อังกฤษ),เวลาใช้(ไทย),เวลาใช้(อังกฤษ)", "50,50,160,160,160,160", "1,1,1,1,1,1", "1,1,1,1,1,1")
        's.SetShowInDown = False
        s2.SetShowBorder = True
    End Sub

    Private Sub filterMasdrguseByDrug(UGID As String)
        Dim s2 As FILTERCLASS
        Dim sql2 As String = "SELECT CAST(USEID AS CHAR(8)) AS USEID, `DUSENAME`, `DUSENAME_EN`, `UGID` FROM masdrguse WHERE STATUS = '1' AND UGID = '" & UGID & "'"
        s2 = New FILTERCLASS(masdrguseTxt, sql2, "รหัส,วิธีใช้(ไทย),วิธีใช้(อังกฤษ),คำย่อ", "50,160,160,50", "1,1,1,1", "1,1,1,1")
        's.SetShowInDown = False
        s2.SetShowBorder = True
    End Sub

    Private Sub filterMasunitDrug()
        Dim s2 As FILTERCLASS
        Dim sql2 As String = "SELECT CAST(UNITID AS CHAR(8)) AS UNITID, UNITNAME_TH, UNITNAME_EN FROM masunit WHERE STATUS = '1' AND F_TIME <> '1'"
        s2 = New FILTERCLASS(u_unitTxt, sql2, "รหัส,หน่วย(ไทย),หน่วย(อังกฤษ)", "50,110,110", "1,1,1", "1,1,1")
        's.SetShowInDown = False
        s2.SetShowBorder = True
    End Sub

    Private Sub filterMasslabel()
        Dim sM As FILTERCLASS
        Dim sql2 As String = "SELECT CAST(slid AS CHAR(8)) AS slid, wcode, slabelname_th, slabelname_en FROM masslabel WHERE status = '1'"
        sM = New FILTERCLASS(cautionTxt, sql2, "รหัส,code,คำเตือน(ไทย),คำเตือน(อังกฤษ)", "50,50,180,180", "1,1,1,1", "1,1,1,1")
        sM.SetTextIndex = 2
        sM.SetShowInDown = False
        sM.SetShowBorder = True
    End Sub

    'Private Sub filterDrugLabel()
    '    Dim s2 As FILTERCLASS
    '    Dim sql2 As String = "SELECT DUSEID, DLABEL FROM frndrguse GROUP BY DLABEL"
    '    s2 = New FILTERCLASS(dlabelTxt, sql2, "รหัส,ฉลากยา(ไทย)", "400,400", "0,1", "1,1")
    '    's.SetShowInDown = False
    '    s2.SetShowBorder = True
    'End Sub

    'Private Sub filterDrugLabelEn()
    '    Dim s2 As FILTERCLASS
    '    Dim sql2 As String = "SELECT DUSEID, DLABEL_EN FROM frndrguse GROUP BY DLABEL"
    '    s2 = New FILTERCLASS(dlabelEnTxt, sql2, "รหัส,ฉลากยา(อังกฤษ)", "400,400", "0,1", "1,1")
    '    's.SetShowInDown = False
    '    s2.SetShowBorder = True
    'End Sub

    'Private Sub filterMasslabel()
    '    Dim s2 As FILTERCLASS
    '    Dim sql2 As String = "SELECT CAST(SLID AS CHAR(8)) AS SLID, SLABELNAME_TH, SLABELNAME_EN FROM masslabel WHERE STATUS = '1'"
    '    s2 = New FILTERCLASS(cautionTxt, sql2, "รหัส,คำเตือน(ไทย),คำเตือน(อังกฤษ)", "50,200,200", "1,1,1", "1,1,1")
    '    's.SetShowInDown = False
    '    s2.SetShowBorder = True
    'End Sub

    'Private Sub filterMasslabelEN()
    '    Dim s2 As FILTERCLASS
    '    Dim sql2 As String = "SELECT CAST(SLID AS CHAR(8)) AS SLID, SLABELNAME_EN, SLABELNAME_TH FROM masslabel WHERE STATUS = '1'"
    '    s2 = New FILTERCLASS(caution_enTxt, sql2, "รหัส,คำเตือน(อังกฤษ),คำเตือน(ไทย)", "50,200,200", "1,1,1", "1,1,1")
    '    's.SetShowInDown = False
    '    s2.SetShowBorder = True
    'End Sub

    'Private Sub filterMasunitTime()
    '    Dim s2 As FILTERCLASS
    '    Dim sql2 As String = "SELECT CAST(UNITID AS CHAR(8)) AS UNITID, UNITNAME_TH, UNITNAME_EN FROM masunit WHERE STATUS = '1' AND F_TIME = '1' AND UNITID <> '29' AND UNITID <> '30'"
    '    s2 = New FILTERCLASS(t_unitTxt, sql2, "รหัส,เวลา(ไทย),เวลา(อังกฤษ)", "50,110,110", "1,1,1", "1,1,1")
    '    s2.SetShowInDown = False
    '    s2.SetShowBorder = True
    'End Sub

    Private Sub txtDrgcuse_TextChanged(sender As Object, e As EventArgs) Handles txtDrgcuse.TextChanged
        If txtDrgcuse.Tag IsNot Nothing And Convert.ToString(txtDrgcuse.Tag) <> "" Then
            Dim objGetDrgcuseInfo As New DRUGUSE2CLASS
            Dim dt As DataTable = objGetDrgcuseInfo.selectDrgcuse(txtDrgcuse.Tag)

            If dt.Rows(0)("qlabel") IsNot DBNull.Value Then
                txtQlabel.Text = dt.Rows(0)("qlabel")
            Else
                txtQlabel.Clear()
            End If

            If dt.Rows(0)("qlabel_en") IsNot DBNull.Value Then
                txtQlabel_en.Text = dt.Rows(0)("qlabel_en")
            Else
                txtQlabel_en.Clear()
            End If

            If dt.Rows(0)("mlabel") IsNot DBNull.Value Then
                txtMlabel.Text = dt.Rows(0)("mlabel")
            Else
                txtMlabel.Clear()
            End If

            If dt.Rows(0)("mlabel_en") IsNot DBNull.Value Then
                txtMlabel_en.Text = dt.Rows(0)("mlabel_en")
            Else
                txtMlabel_en.Clear()
            End If

            labelCombination()
        End If
    End Sub

    Private Sub cautionTxt_TextChanged(sender As Object, e As EventArgs) Handles cautionTxt.TextChanged
        If cautionTxt.Tag IsNot Nothing And Convert.ToString(cautionTxt.Tag) <> "" Then
            Dim objGetSlabel As New DRUGUSE2CLASS
            Dim dt As DataTable = objGetSlabel.selectSlabel(cautionTxt.Tag)

            If dt.Rows(0)("slabelname_th") IsNot DBNull.Value Then
                txtMasslabelManual.Text = dt.Rows(0)("slabelname_th")
            End If

            If dt.Rows(0)("slabelname_en") IsNot DBNull.Value Then
                caution_enTxt.Text = dt.Rows(0)("slabelname_en")
            End If
        End If
    End Sub

    Private Sub masdrguseTxt_TextChanged(sender As Object, e As EventArgs) Handles masdrguseTxt.TextChanged
        If masdrguseTxt.Tag IsNot Nothing And Convert.ToString(masdrguseTxt.Tag) <> "" Then
            Dim objGetMasdrguse As New DRUGUSE2CLASS
            Dim dt As DataTable = objGetMasdrguse.selectMasdrguse(masdrguseTxt.Tag)

            If dt.Rows(0)("dusename_en") IsNot DBNull.Value Then
                txtMasdrguseEn.Text = dt.Rows(0)("dusename_en")
            End If

            labelCombination()
        End If
    End Sub

    Private Sub DRUGUSE2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DesignForm(Me)
        DesignGrid(frndruguseGrid)

        queryFrndrguseGrid()

        filterGridChk.Checked = False
        ckbEnableSlabel.Checked = False

        txtMasslabelManual.Visible = True
        cautionTxt.Visible = False

        filterDrugitem()
        'filterMasdrguse()
        filterMasdrgcuse()
        filterMasunitDrug()
        filterMasslabel()
        'filterMasslabel()
        'filterMasslabelEN()
        'filterMasunitTime()
        'filterDrugLabel()
        'filterDrugLabelEn()

        PROVIDER_Check.GETHOSEM(CStr(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub PRDCODETxt_TextChanged(sender As Object, e As EventArgs) Handles DRGCODETxt.TextChanged
        Dim objGetPRDCODE As New GETPRDFROMDRG
        Dim prdcode As Integer = objGetPRDCODE.getPRDCODE(DRGCODETxt.Tag)

        Try
            Dim tradenameDT As String
            tradenameDT = connect.GetTable("SELECT TRADENAME FROM drugitem WHERE DRGCODE = '" & DRGCODETxt.Tag & "'").Rows(0)(0)
            tradenameTxt.Text = tradenameDT
        Catch ex As Exception
            tradenameTxt.Clear()
        End Try

        Try
            Dim UGID As String = connect.GetTable("SELECT UGID FROM drugitem WHERE PRDCODE = '" & prdcode & "'").Rows(0)("UGID")
            filterMasdrguseByDrug(UGID)
        Catch ex As Exception
            'ถ้าไม่เจอวิธีการใช้ยาจาก drugitem
            filterMasdrguse()
        End Try

        Try
            'กรองหน่วยการใช้
            Dim sql As String = "SELECT a.`U_UNIT` AS 'unit', b.`UNITNAME_TH` AS 'unitName' FROM masproduct a LEFT JOIN masunit b ON a.`U_UNIT` = b.`UNITID` WHERE a.PRDCODE = '" & prdcode & "'"

            Dim dt As New DataTable
            dt = connect.GetTable(sql)

            If dt.Rows(0)("unit") IsNot DBNull.Value And dt.Rows(0)("unitName") IsNot DBNull.Value Then
                u_unitTxt.Tag = dt.Rows(0)("unit")
                u_unitTxt.Text = dt.Rows(0)("unitName")
            Else
                u_unitTxt.Clear()
            End If
        Catch ex As Exception
            u_unitTxt.Clear()
        End Try
    End Sub

    Private Function HALFString() As String
        Return "ครึ่ง"
    End Function
    Private Function modnumber(num1 As Integer, num2 As Integer) As Integer
        Return num1 Mod num2
    End Function
    Private Function divideNumber(num1 As Integer, num2 As Integer) As Integer
        Return num1 \ num2
    End Function
    Private Function ConvertStringTonum(str As String) As String
        Select Case str
            Case "สิบ"
                Return "10"
            Case "เก้า"
                Return "9"
            Case "แปด"
                Return "8"
            Case "เจ็ด"
                Return "7"
            Case "หก"
                Return "6"
            Case "ห้า"
                Return "5"
            Case "สี่"
                Return "4"
            Case "สาม"
                Return "3"
            Case "สอง"
                Return "2"
            Case "หนึ่ง"
                Return "1"
            Case Else
                Return ""
        End Select

    End Function
    Private Function convertNumToStringThai(num As Integer) As String
        Select Case num
            Case 10
                Return "สิบ"
            Case "9"
                Return "เก้า"
            Case "8"
                Return "แปด"
            Case "7"
                Return "เจ็ด"
            Case "6"
                Return "หก"
            Case "5"
                Return "ห้า"
            Case "4"
                Return "สี่"
            Case "3"
                Return "สาม"
            Case "2"
                Return "สอง"
            Case "1"
                Return "หนึ่ง"
            Case Else
                Return ""
        End Select
    End Function

    Public Function convertSubScaleToStringTH(str As String) As String
        If str.ToString <> "" Then
            Dim finalValueTH As String

            Dim arrDrgQuanFloat As Array
            arrDrgQuanFloat = str.Split("/")

            If arrDrgQuanFloat(0) = "" Or arrDrgQuanFloat(1) = "" Then
                Return str
            ElseIf arrDrgQuanFloat(0) = arrDrgQuanFloat(1) Then
                finalValueTH = 1
                Return finalValueTH
                Exit Function
            End If

            ' กรณีที่ ตัวหน้า คูณ*2 เท่ากับตัวหลัง จะเป็นครึ่งหนึ่ง 
            If CInt(arrDrgQuanFloat(0)) * 2 = CInt(arrDrgQuanFloat(1)) Then
                finalValueTH = DRUGUSE2CLASS.HALFString()
                Return finalValueTH
                'กรณีที่ คูณ 2ไม่เท่ากับด้านหลัง
            ElseIf CInt(arrDrgQuanFloat(0)) * 2 <> CInt(arrDrgQuanFloat(1)) Then
                ' เช็ค ว่าตัวหน้ามากกว่าตัวหลังหรือปล่าว 
                If CInt(arrDrgQuanFloat(0)) > CInt(arrDrgQuanFloat(1)) Then
                    'เช็คว่าตัว mod เท่ากับ 0 ไหม ตัวอย่าง 9/3 = 0 , 4/2 =0 2/1 = 0
                    If DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) = 0 Then
                        finalValueTH = DRUGUSE2CLASS.convertNumToStringThai(CInt(arrDrgQuanFloat(0)) \ (CInt(arrDrgQuanFloat(1))))
                        Return finalValueTH
                    Else
                        ' หารเอาตัวหน้า 9/2  จะได้คำแรกมาคือ สี่ 
                        finalValueTH = DRUGUSE2CLASS.convertNumToStringThai(DRUGUSE2CLASS.divideNumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))))
                        'เช็คเศษ กรณีแรกเช็ค ว่าเศษเป็นครึ่งหนึ่งของส่วนหรือปล่าว 1/2
                        If DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) * 2 = CInt(arrDrgQuanFloat(1)) Then
                            'กรณีที่เศษ ไม่เป็นครึ่งหนึ่งของส่วน
                            finalValueTH += u_unitTxt.Text + DRUGUSE2CLASS.HALFString()
                            Return finalValueTH
                        Else
                            ' กรณีเศษเป็นครึ่งนึงของส่วน เช่น 4 2/4
                            finalValueTH += " เศษ" + DRUGUSE2CLASS.convertNumToStringThai(DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1)))) + "ส่วน" + DRUGUSE2CLASS.convertNumToStringThai(CInt(arrDrgQuanFloat(1)))
                            Return finalValueTH
                        End If
                    End If
                Else
                    finalValueTH = DRUGUSE2CLASS.convertNumToStringThai(CInt(arrDrgQuanFloat(0))) + "ส่วน" + DRUGUSE2CLASS.convertNumToStringThai(CInt(arrDrgQuanFloat(1)))
                    Return finalValueTH
                End If
            End If
        End If
    End Function

    Public Function convertSubScaleToStringEN(str As String) As String
        If str.ToString <> "" Then
            Dim finalValueEN As String

            Dim arrDrgQuanFloat As Array
            arrDrgQuanFloat = str.Split("/")

            If arrDrgQuanFloat(0) = "" Or arrDrgQuanFloat(1) = "" Then
                Return str
            ElseIf arrDrgQuanFloat(0) = arrDrgQuanFloat(1) Then
                finalValueEN = 1
                Return finalValueEN
                Exit Function
            End If

            ' กรณีที่ ตัวหน้า คูณ*2 เท่ากับตัวหลัง จะเป็นครึ่งหนึ่ง 
            If CInt(arrDrgQuanFloat(0)) * 2 = CInt(arrDrgQuanFloat(1)) Then
                finalValueEN = arrDrgQuanFloat(0) + "/" + arrDrgQuanFloat(1) + " "
                Return finalValueEN
                'กรณีที่ คูณ 2ไม่เท่ากับด้านหลัง
            ElseIf CInt(arrDrgQuanFloat(0)) * 2 <> CInt(arrDrgQuanFloat(1)) Then
                ' เช็ค ว่าตัวหน้ามากกว่าตัวหลังหรือปล่าว 
                If CInt(arrDrgQuanFloat(0)) > CInt(arrDrgQuanFloat(1)) Then
                    'เช็คว่าตัว mod เท่ากับ 0 ไหม ตัวอย่าง 9/3 = 0 , 4/2 =0 2/1 = 0
                    If DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) = 0 Then
                        finalValueEN = CStr(CInt(arrDrgQuanFloat(0)) \ (CInt(arrDrgQuanFloat(1))))
                        Return finalValueEN
                    Else
                        ' หารเอาตัวหน้า 9/2  จะได้คำแรกมาคือ สี่ 
                        finalValueEN = arrDrgQuanFloat(0) \ arrDrgQuanFloat(1)
                        'เช็คเศษ กรณีแรกเช็ค ว่าเศษเป็นครึ่งหนึ่งของส่วนหรือปล่าว 1/2
                        If DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) * 2 = CInt(arrDrgQuanFloat(1)) Then
                            'กรณีที่เศษ ไม่เป็นครึ่งหนึ่งของส่วน
                            finalValueEN += " " + "1/2"
                            Return finalValueEN
                        Else
                            ' กรณีเศษเป็นครึ่งนึงของส่วน เช่น 4 2/4
                            finalValueEN += " " & DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) & "/" & arrDrgQuanFloat(1)
                            Return finalValueEN
                        End If
                    End If
                Else
                    finalValueEN = arrDrgQuanFloat(0) + "/" + arrDrgQuanFloat(1)
                    Return finalValueEN
                End If
            End If
        End If
    End Function

    Public Sub labelCombination()

        Dim useDT As DataTable = connect.GetTable("SELECT DUSENAME, DUSENAME_EN, UGID FROM masdrguse WHERE USEID = '" & masdrguseTxt.Tag & "'")

        If useDT.Rows.Count = 0 Then
            useTextTH = ""
            useTextEN = ""
        Else
            If useDT.Rows(0)("DUSENAME") IsNot DBNull.Value Then
                useTextTH = useDT.Rows(0)("DUSENAME")
            Else
                useTextTH = ""
            End If

            If useDT.Rows(0)("DUSENAME_EN") IsNot DBNull.Value Then
                useTextEN = useDT.Rows(0)("DUSENAME_EN")
            Else
                useTextEN = ""
            End If
        End If

        Dim unitDT As DataTable = connect.GetTable("SELECT UNITNAME_TH, UNITNAME_EN FROM masunit WHERE UNITID = '" & u_unitTxt.Tag & "'")

        If unitDT.Rows.Count = 0 Then
            unitTH = ""
            unitEN = ""
        Else
            If unitDT.Rows(0)("UNITNAME_TH") IsNot DBNull.Value Then
                unitTH = unitDT.Rows(0)("UNITNAME_TH")
            Else
                unitTH = ""
            End If

            If unitDT.Rows(0)("UNITNAME_EN") IsNot DBNull.Value Then
                unitEN = unitDT.Rows(0)("UNITNAME_EN")
            Else
                unitEN = ""
            End If
        End If

        Dim dtMasdrgcuse As DataTable
        dtMasdrgcuse = connect.GetTable("SELECT qlabel, qlabel_en, mlabel, mlabel_en FROM masdrgcuse WHERE dcuid = '" & txtDrgcuse.Tag & "'")

        If dtMasdrgcuse.Rows.Count = 0 Then
            publicQlabel = ""
            publicQlabel_en = ""
            publicMlabel = ""
            publicMlabel_en = ""
        Else
            If dtMasdrgcuse.Rows(0)("qlabel") IsNot DBNull.Value Then
                publicQlabel = dtMasdrgcuse.Rows(0)("qlabel")
            Else
                publicQlabel = ""
            End If

            If dtMasdrgcuse.Rows(0)("qlabel_en") IsNot DBNull.Value Then
                publicQlabel_en = dtMasdrgcuse.Rows(0)("qlabel_en")
            Else
                publicQlabel_en = ""
            End If

            If dtMasdrgcuse.Rows(0)("mlabel") IsNot DBNull.Value Then
                publicMlabel = dtMasdrgcuse.Rows(0)("mlabel")
            Else
                publicMlabel = ""
            End If

            If dtMasdrgcuse.Rows(0)("mlabel_en") IsNot DBNull.Value Then
                publicMlabel_en = dtMasdrgcuse.Rows(0)("mlabel_en")
            Else
                publicMlabel_en = ""
            End If
        End If

        If txtQty.Text.Length.ToString > 0 Then

            If txtQty.Text.Contains("/") Then
                Dim scaleTH As String = convertSubScaleToStringTH(txtQty.Text.Trim)
                Dim scaleEN As String = convertSubScaleToStringEN(txtQty.Text.Trim)
                Dim rawScale As String = txtQty.Text.Trim


                'เช็คว่าเป็นเศษเกินหรือไม่ ถ้าเป็นเศษเกิน ไม่ต้องรวมหน่วยเข้ามาในฉลาก ไปรวมตอนแปลงคำแทน
                Dim arrDrgQuanFloat As Array
                arrDrgQuanFloat = rawScale.Split("/")

                If arrDrgQuanFloat(0) = "" Or arrDrgQuanFloat(1) = "" Then
                    dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                    dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                    Exit Sub
                ElseIf arrDrgQuanFloat(0) = arrDrgQuanFloat(1) Then
                    dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                    dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                    Exit Sub
                End If

                If CInt(arrDrgQuanFloat(0)) * 2 = CInt(arrDrgQuanFloat(1)) Then
                    dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                    dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                    'กรณีที่ คูณ 2ไม่เท่ากับด้านหลัง
                ElseIf CInt(arrDrgQuanFloat(0)) * 2 <> CInt(arrDrgQuanFloat(1)) Then
                    ' เช็ค ว่าตัวหน้ามากกว่าตัวหลังหรือปล่าว 
                    If CInt(arrDrgQuanFloat(0)) > CInt(arrDrgQuanFloat(1)) Then
                        'เช็คว่าตัว mod เท่ากับ 0 ไหม ตัวอย่าง 9/3 = 0 , 4/2 =0 2/1 = 0
                        If DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) = 0 Then
                            dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                            dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                        Else
                            ' หารเอาตัวหน้า 9/2  จะได้คำแรกมาคือ สี่ 
                            dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                            dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                            'เช็คเศษ กรณีแรกเช็ค ว่าเศษเป็นครึ่งหนึ่งของส่วนหรือปล่าว 1/2
                            If DRUGUSE2CLASS.modnumber(CInt(arrDrgQuanFloat(0)), CInt(arrDrgQuanFloat(1))) * 2 = CInt(arrDrgQuanFloat(1)) Then
                                'กรณีที่เศษ ไม่เป็นครึ่งหนึ่งของส่วน
                                dlabelTxt.Text = useTextTH & " " & scaleTH & " " & publicQlabel & " " & publicMlabel
                                dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                            Else
                                ' กรณีเศษเป็นครึ่งนึงของส่วน เช่น 4 2/4
                                dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                                dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                            End If
                        End If
                    Else
                        dlabelTxt.Text = useTextTH & " " & scaleTH & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                        dlabelEnTxt.Text = useTextEN & " " & scaleEN & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
                    End If
                End If
            Else
                dlabelTxt.Text = useTextTH & " " & txtQty.Text.Trim & " " & unitTH & " " & publicQlabel & " " & publicMlabel
                dlabelEnTxt.Text = useTextEN & " " & txtQty.Text.Trim & " " & unitEN & " " & publicQlabel_en & " " & publicMlabel_en
            End If

        End If

        connect.Dispose()
    End Sub

    Public Function CHECKKEY(e As KeyPressEventArgs) As Boolean
        If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Then ' number

            Return False
        ElseIf Asc(e.KeyChar) = 46 Or Asc(e.KeyChar) = 47 Or Asc(e.KeyChar) = 8 Then 'Dot ANd /
            Return False
        Else
            Return True
        End If
    End Function


    Private Sub filterGridChk_CheckedChanged(sender As Object, e As EventArgs) Handles filterGridChk.CheckedChanged
        Dim objGetPRDCODE As New GETPRDFROMDRG
        Dim prdcode As Integer = objGetPRDCODE.getPRDCODE(DRGCODETxt.Tag)

        If filterGridChk.Checked = True Then
            queryFilterFrndrguseGrid(prdcode)
        Else
            queryFrndrguseGrid()
        End If
    End Sub

    Private Sub ckbEnableSlabel_CheckedChanged(sender As Object, e As EventArgs) Handles ckbEnableSlabel.CheckedChanged
        If ckbEnableSlabel.Checked = True Then
            cautionTxt.Visible = True
            txtMasslabelManual.Visible = False
        Else
            cautionTxt.Visible = False
            txtMasslabelManual.Visible = True
        End If
    End Sub

    Private Sub u_unitTxt_TextChanged(sender As Object, e As EventArgs) Handles u_unitTxt.TextChanged
        If u_unitTxt.Tag IsNot Nothing And Convert.ToString(u_unitTxt.Tag) <> "" Then
            labelCombination()
        End If
    End Sub

    Private Sub txtQty_TextChanged(sender As Object, e As EventArgs) Handles txtQty.TextChanged
        labelCombination()
    End Sub

    Private Sub frndruguseGrid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles frndruguseGrid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสการใช้ยา").Value() IsNot DBNull.Value Then
            DUSEIDTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสการใช้ยา").Value()
        Else
            DUSEIDTxt.Clear()
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสยา").Value() IsNot DBNull.Value Then
            DRGCODETxt.Tag = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสยา").Value()
        Else
            DRGCODETxt.Clear()
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ชื่อผลิตภัณฑ์").Value() IsNot DBNull.Value Then
            DRGCODETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ชื่อผลิตภัณฑ์").Value()
        Else
            DRGCODETxt.Clear()
        End If

        'If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("อัตราส่วน").Value() IsNot DBNull.Value Then
        '    scaleTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("อัตราส่วน").Value()
        'Else
        '    scaleTxt.Clear()
        'End If

        'If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหน่วยนับเวลา").Value() IsNot DBNull.Value Then
        '    t_unitTxt.Tag = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหน่วยนับเวลา").Value()
        'Else
        '    t_unitTxt.Clear()
        'End If

        'If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("หน่วยนับเวลา").Value() IsNot DBNull.Value Then
        '    t_unitTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("หน่วยนับเวลา").Value()
        'Else
        '    t_unitTxt.Clear()
        'End If

        'If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสผลิตภัณฑ์").Value() IsNot DBNull.Value Then
        '    t_unitTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสผลิตภัณฑ์").Value()
        'Else
        '    t_unitTxt.Clear()
        'End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("จำนวนต่อมื้อ").Value() IsNot DBNull.Value Then
            txtQty.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("จำนวนต่อมื้อ").Value()
        Else
            txtQty.Clear()
        End If

        '----drgcuse----
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสบริโภคยา").Value() IsNot DBNull.Value Then
            txtDrgcuse.Tag = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสบริโภคยา").Value()
        Else
            txtDrgcuse.Tag = ""
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("code การบริโภคยา").Value() IsNot DBNull.Value Then
            txtDrgcuse.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("code การบริโภคยา").Value()
        Else
            txtDrgcuse.Text = ""
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("จำนวนการบริโภคไทย").Value() IsNot DBNull.Value Then
            txtQlabel.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("จำนวนการบริโภคไทย").Value()
        Else
            txtQlabel.Text = ""
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("จำนวนการบริโภคอังกฤษ").Value() IsNot DBNull.Value Then
            txtQlabel_en.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("จำนวนการบริโภคอังกฤษ").Value()
        Else
            txtQlabel_en.Text = ""
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("เวลาบริโภคไทย").Value() IsNot DBNull.Value Then
            txtMlabel.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("เวลาบริโภคไทย").Value()
        Else
            txtMlabel.Text = ""
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("เวลาบริโภคอังกฤษ").Value() IsNot DBNull.Value Then
            txtMlabel_en.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("เวลาบริโภคอังกฤษ").Value()
        Else
            txtMlabel_en.Clear()
        End If

        '----end of drgcuse----

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสวิธีการใช้ยา").Value() IsNot DBNull.Value Then
            masdrguseTxt.Tag = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสวิธีการใช้ยา").Value()
        Else
            masdrguseTxt.Tag = ""
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("วิธีการใช้ยา").Value() IsNot DBNull.Value Then
            masdrguseTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("วิธีการใช้ยา").Value()
        Else
            masdrguseTxt.Clear()
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลาก").Value() IsNot DBNull.Value Then
            dlabelTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลาก").Value()
        Else
            dlabelTxt.Clear()
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลากภาษาอังกฤษ").Value() IsNot DBNull.Value Then
            dlabelEnTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลากภาษาอังกฤษ").Value()
        Else
            dlabelEnTxt.Clear()
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหน่วยนับยา").Value() IsNot DBNull.Value Then
            u_unitTxt.Tag = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหน่วยนับยา").Value()
        Else
            u_unitTxt.Clear()
        End If

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("หน่วยนับยา").Value() IsNot DBNull.Value Then
            u_unitTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("หน่วยนับยา").Value()
        Else
            u_unitTxt.Clear()
        End If

        stopTEvent = 1
        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสคำเตือน").Value() IsNot DBNull.Value Then

            Try
                cautionTxt.Tag = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสคำเตือน").Value()
            Catch ex As Exception
                cautionTxt.Clear()
            End Try

            Try
                cautionTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลากคำเตือนไทย").Value()
                txtMasslabelManual.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลากคำเตือนไทย").Value()
            Catch ex As Exception
                cautionTxt.Clear()
                txtMasslabelManual.Clear()
            End Try

            Try
                caution_enTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("ฉลากคำเตือนอังกฤษ").Value()
            Catch ex As Exception
                caution_enTxt.Clear()
            End Try
        Else
            If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำเตือนเสริมไทย").Value() IsNot DBNull.Value Then
                txtMasslabelManual.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำเตือนเสริมไทย").Value().ToString
                cautionTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำเตือนเสริมไทย").Value().ToString
            Else
                txtMasslabelManual.Clear()
                cautionTxt.Clear()
            End If

            If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำเตือนเสริมอังกฤษ").Value() IsNot DBNull.Value Then
                caution_enTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("คำเตือนเสริมอังกฤษ").Value().ToString
            Else
                caution_enTxt.Clear()
            End If
        End If
        stopTEvent = 0

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            frndrguseStatusChk.Checked = True
        Else
            frndrguseStatusChk.Checked = False
        End If

        Dim objChkboxUpdate As New CLICKGRIDCHECKBOX
        objChkboxUpdate.clickChkboxUpdate("frndrguse", CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value(), "STATUS", "DUSEID", DUSEIDTxt.Text)
    End Sub

    Private Sub clearForm()
        DRGCODETxt.Clear()
        DRGCODETxt.Tag = ""
        tradenameTxt.Clear()

        masdrguseTxt.Clear()
        masdrguseTxt.Tag = ""

        txtQty.Clear()

        u_unitTxt.Clear()
        u_unitTxt.Tag = ""

        txtDrgcuse.Clear()
        txtDrgcuse.Tag = ""
        txtQlabel.Clear()
        txtMlabel.Clear()
        txtQlabel_en.Clear()
        txtMlabel_en.Clear()

        dlabelTxt.Clear()
        dlabelEnTxt.Clear()

        cautionTxt.Clear()
        cautionTxt.Tag = ""
        txtMasslabelManual.Clear()
        caution_enTxt.Clear()
        'scaleTxt.Clear()
        't_unitTxt.Clear()
        frndrguseStatusChk.Checked = False
        DUSEIDTxt.Clear()
    End Sub

    Private Sub addFrndrguse_Click(sender As Object, e As EventArgs) Handles addFrndrguse.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If DRGCODETxt.Text.Length.ToString > 0 And u_unitTxt.Text.Length.ToString > 0 And txtQty.Text.Length.ToString > 0 Then
                    Dim objInsertData As New DRUGUSE2CLASS

                    Dim objGetPRDCODE As New GETPRDFROMDRG
                    objInsertData.PRDCODE_ = objGetPRDCODE.getPRDCODE(DRGCODETxt.Tag)

                    objInsertData.DLABEL_ = dlabelTxt.Text
                    objInsertData.DLABEL_EN_ = dlabelEnTxt.Text
                    'objInsertData.SCALE_ = scaleTxt.Text
                    'objInsertData.T_UNIT_ = t_unitTxt.Tag
                    objInsertData.QTY_ = txtQty.Text
                    objInsertData.U_UNIT_ = u_unitTxt.Tag
                    objInsertData.USEID_ = masdrguseTxt.Tag
                    objInsertData.DCUID_ = txtDrgcuse.Tag

                    If cautionTxt.Visible = True Then
                        objInsertData.SLID_ = cautionTxt.Tag
                        objInsertData.CAUTION_ = cautionTxt.Text
                        objInsertData.CAUTION_EN_ = caution_enTxt.Text.Trim
                    Else
                        objInsertData.CAUTION_ = txtMasslabelManual.Text.Trim
                        objInsertData.CAUTION_EN_ = caution_enTxt.Text.Trim
                    End If

                    objInsertData.STATUS_ = frndrguseStatusChk.Checked
                    objInsertData.USMK_ = PROVIDER_Check.GETPROVIDER(main.txtUserRequest.Text)

                    If objInsertData.insertFrndrguse() = True Then
                        MsgBox("ท่านได้ทำการเพิ่มรูปแบบการใช้ยาเรียบร้อยแล้ว")
                        queryFrndrguseGrid()
                        clearForm()
                    End If
                Else
                    MsgBox("โปรดกรุณาระบุข้อมูลชื่อยา การใช้ยา หน่วยยา อัตราการใช้ต่อวันให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editFrndrguse_Click(sender As Object, e As EventArgs) Handles editFrndrguse.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If DRGCODETxt.Text.Length.ToString > 0 And u_unitTxt.Text.Length.ToString > 0 And txtQty.Text.Length.ToString > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขวิธีการใช้ยาดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        'connectlocal = conlocal.NewConnection
                        Dim objEditData As New DRUGUSE2CLASS
                        objEditData.DUSEID_ = DUSEIDTxt.Text

                        Dim objGetPRDCODE As New GETPRDFROMDRG
                        'MsgBox(DRGCODETxt.Tag)
                        objEditData.PRDCODE_ = objGetPRDCODE.getPRDCODE(DRGCODETxt.Tag)

                        objEditData.DLABEL_ = dlabelTxt.Text
                        objEditData.DLABEL_EN_ = dlabelEnTxt.Text
                        'objInsertData.SCALE_ = scaleTxt.Text
                        'objInsertData.T_UNIT_ = t_unitTxt.Tag
                        objEditData.QTY_ = txtQty.Text
                        objEditData.U_UNIT_ = u_unitTxt.Tag
                        objEditData.USEID_ = masdrguseTxt.Tag
                        objEditData.DCUID_ = txtDrgcuse.Tag

                        If cautionTxt.Visible = True Then
                            objEditData.SLID_ = cautionTxt.Tag
                            objEditData.CAUTION_ = cautionTxt.Text
                            objEditData.CAUTION_EN_ = caution_enTxt.Text.Trim
                        Else
                            objEditData.CAUTION_ = txtMasslabelManual.Text.Trim
                            objEditData.CAUTION_EN_ = caution_enTxt.Text.Trim
                        End If

                        objEditData.STATUS_ = frndrguseStatusChk.Checked
                        objEditData.USMK_ = PROVIDER_Check.GETPROVIDER(main.txtUserRequest.Text)

                        If objEditData.editFrndrguse() = True Then
                            MsgBox("ท่านได้ทำการแก้ไขรูปแบบการใช้ยาเรียบร้อยแล้ว")
                            queryFrndrguseGrid()
                            clearForm()
                        End If
                    End If
                Else
                    MsgBox("ท่านต้องทำการกรอกข้อมูลให้ครบถ้วนก่อนทำการแก้ไขข้อมูล")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub btnClearForm_Click(sender As Object, e As EventArgs) Handles btnClearForm.Click
        clearForm()
        queryFrndrguseGrid()
    End Sub



End Class